# -*- coding: utf-8 -*-
# encoding:utf-8

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import mongoengine
from sqlalchemy import Column, String, Integer, ForeignKey
from sqlalchemy.ext.declarative import declarative_base


DB_HOST = '127.0.0.1'
DB_USER = 'root'
DB_PWD = '084358'
# DB_NAME = 'herald_webservice'
DB_NAME = 'data'

Base = declarative_base()
engine = create_engine('mysql://%s:%s@%s/%s?charset=utf8' %
                       (DB_USER, DB_PWD, DB_HOST, DB_NAME), echo=False,pool_size=500, pool_recycle=100)



mongoengine.connect('the_my_zhihu_data',host="127.0.0.1",port=27017,username="",password="")


class Zhihu_User_Profile(mongoengine.Document):
    user_name = mongoengine.StringField()
    user_be_agreed = mongoengine.StringField()
    user_be_thanked = mongoengine.StringField()
    user_followees = mongoengine.StringField()
    user_followers = mongoengine.StringField()
    user_education_school = mongoengine.StringField()
    user_education_subject = mongoengine.StringField()
    user_employment = mongoengine.StringField()
    user_employment_extra = mongoengine.StringField()
    user_location = mongoengine.StringField()
    user_gender = mongoengine.StringField()
    user_info = mongoengine.StringField()
    user_intro = mongoengine.StringField()
    user_url = mongoengine.StringField()



class ZhiHuUser(Base):
    __tablename__ = 'zhihu'
    id = Column(Integer, primary_key=True)
    user_name = Column(String(512))
    user_be_agreed = Column(String(512))
    user_be_thanked = Column(String(512))
    user_followees = Column(String(512))
    user_followers = Column(String(512))
    user_education_school = Column(String(512))
    user_education_subject = Column(String(512))
    user_employment = Column(String(512))
    user_employment_extra = Column(String(512))
    user_location = Column(String(512))
    user_gender = Column(String(512))
    user_info = Column(String(512))
    user_intro = Column(String(512))
    user_url = Column(String(512))

class Follower(Base):
    __tablename__ = 'follower'
    id = Column(Integer, primary_key=True)
    source = Column(String(512))
    target = Column(String(512))

Base.metadata.create_all(engine)